import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.*;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableRowSorter;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.*;

//NOTE: to get this to show up you need to create an object it in the Home Panel
public class AddAdmitPanel extends JPanel implements ActionListener{ 
	private JButton screenButton;													
	private JPanel format;
	private ProcessClientPanel pcp;
	private AddClientPanel acp;
	private ScreenedClientList scl;
	private ScreenedClient sc;
	private ImageIcon icon;
	private ScreenedClient sc2;
	
	public AddAdmitPanel(){
		sc = new ScreenedClient();
		format = new JPanel(new GridLayout(2,1));
		format.setBackground(Color.WHITE);
		pcp = new ProcessClientPanel();
		acp = new AddClientPanel();
      icon = createImageIcon("images/icon.png");
		
		format.add(acp);
		format.add(pcp);
		this.add(format);
		screenButton = new JButton("Finish");
		screenButton.addActionListener(this);
		this.add(screenButton);
	}
	
	protected static ImageIcon createImageIcon(String path) { //used to create tab image
                java.net.URL imgURL = HomePanel.class.getResource(path);
                if (imgURL != null) {
                    return new ImageIcon(imgURL);
                } else {
                    System.err.println("Couldn't find file: " + path);
                    return null;
                }
            }
	
	public void actionPerformed(ActionEvent evt){
		if(evt.getSource() == screenButton){//this action will create an object of the ScreenedClient and add it to the table
			String f = pcp.getFirstName();
			String l = pcp.getLastName();
			String m = pcp.getMonth();
			String d = pcp.getDate();
			String y = pcp.getYear();
			int a = pcp.getAge();
			String e = pcp.getEthnicity();
			String sm = pcp.getSMonth();
			String sd = pcp.getSDate();
			String sy = pcp.getSYear();
			ScreenedClient nc = new ScreenedClient(f,l,m,d,y,a,e,sm,sd,sy);
			acp.addRow(nc);
			pcp.clearTextFields();
		}
	}
}